module.exports = async function(ctx, next) {
    let code = 0;
    let message = "ok";
    try {
        await next();
    } catch (e) {
        code = e.statusCode || e.status || 500;
        message = e.message;
        ctx.app.emit("error", e, ctx);
    } finally {
        ctx.body = {
            code,
            message,
            data: ctx.body
        };
    }
};
